package Lesson15;

public class Car {
	
	String model;
	int maxSpeed;
	int currentSpeed;
	String color;
	int currentGear;
	Person owner;
	double price;
	boolean isSportCar;
	//private Object ;
	// String ownerOfTheCar = owner.name;
	
	
	Car(double price)
	{
		this.price = price;
	}
	Car(boolean isSportCar)
	{
		 //  this(700); // calls Car(double price)
		this.isSportCar = isSportCar;
	}
	
	Car(String model, boolean isSportCar, String color, double price, int maxSpeed)
	{
		this(true);
		this.model = model;
		this.isSportCar = isSportCar;
		this.color = color;
		this.price = price;
		if(maxSpeed > 200)
		{
			if(isSportCar)
			{
				this.maxSpeed = maxSpeed;
			}
		}
		else
		{
			this.maxSpeed = maxSpeed;
		}
		
		
	}
	
	
	void accelerate()
	{
		currentSpeed += 20;
		if(currentSpeed>=maxSpeed)
		{
			currentSpeed = maxSpeed;	
		}
	}
	void changeGearUp()
	{
		if(currentGear>=6)
		{
			System.out.println("You are on gear 6. There are no more gears!");
		}
		else
			currentGear++;
	}
	void changeGearDown()
	{
		if(currentGear<=1)
		{
			System.out.println("You are on 1st gear. No more gears down!");
		}
		else
			currentGear--;
	}
	void changeGear(int nextGear)
	{
		if(nextGear>=1 && nextGear<=6)
		{
			currentGear = nextGear;
		}
	}
	void changeColor(String newColor)
	{
		color = newColor;
	}
	void printCar(Car car)
	{
		System.out.println(car.model);
		System.out.println(car.maxSpeed);
		System.out.println(car.price);
		System.out.println(car.isSportCar);
	}
	boolean isMoreExpensive(Car car)
	{
		boolean isMoreExpensive = false;
		if(car.price > this.price)
			isMoreExpensive = false;
		else
			isMoreExpensive = true;
		return isMoreExpensive;
		
		/// return this.price > car.price
		
	}
	double calculateCarPriceForScrap(double metalPrice)
	{
		double coef = 0.2;
		if(this.color.equalsIgnoreCase("black") || this.color.equalsIgnoreCase("white"))
		{
			coef = coef + 0.05;
		}
		if(this.isSportCar)
		{
			coef = coef + 0.05;
		}
		this.price = metalPrice*coef;
		return this.price;
	}
	void changeOwner(Person newOwner)
	{
		this.owner = newOwner;
	}

}
